﻿#ifndef _DGRAM_H_
#define _DGRAM_H_

#include "sock.h"
#include "nlist.h"
#include "net_err.h"
#include "ipaddr.h"

typedef struct _dgram_t
{
    sock_t base;
    sock_wait_t recv_wait;
    nlist_t recv_list; // 用于存放socket收到的数据包
} dgram_t;

net_err_t dgram_init();
sock_t *dgram_create(int family, int protocol);
net_err_t dgram_in(pktbuf_t *buf);
dgram_t *dgram_find(ipaddr_t *src_ip, uint16_t sport, ipaddr_t *dst_ip, uint16_t dport);
net_err_t dgram_recvbuf_add(dgram_t *dgram, pktbuf_t *buf);

#endif